<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta content="phalconplus API doc" name="description">
    <title>
                    phalconplus API Documentation
            </title>
    <link rel="stylesheet" type="text/css" href="../../../../asset/static/prettify.css" />

<script src="../../../../asset/static/prettify.js"></script>
<script src="../../../../asset/api_definition.js"></script>


                        <link rel="stylesheet" type="text/css" href="../../../../asset/static/prettify.css" />
                    <link rel="stylesheet" type="text/css" href="../../../../asset/static/zephir-theme.css" />
            
    

                        <script src="../../../../asset/static/prettify.js"></script>
                                    <script src="../../../../asset/api_definition.js"></script>
                    <script src="../../../../asset/static/jquery.min.js"></script>
                    <script src="../../../../asset/static/zephir-doc.js"></script>
                <script>var ZepCurrentPath = '../../../../'</script>
    </head>
 <body onload="prettyPrint()">
        <div id="top-bar">
            <div id="top-left">
                                    phalconplus Documentation <span class="version">v1.0.0-alpha</span>
                            </div>
            <div id="top-right">
            </div>
        </div>
        <div id="body">
            <div id="body-left">
                <div class="header-search">
                    <input class="search-box" placeholder="Search for a class or namespace " type="text" />
                    <div id="menu-wrapper">
                    </div>
                </div>
            </div>
            <div id="body-right">
                <div class="content">
                    
<div class="breadcrumb">
    
    <ul>
        
        <li><a href="../../../../index.html">Home</a></li>
        
                <li><a href="../../../../classes.html">Classes</a></li>
                <li><a href="../../../../class/PhalconPlus/Logger/Formatter/LinePlus.html">PhalconPlus\Logger\Formatter\LinePlus</a></li>
                <li><a >Source</a></li>
                
    </ul>
    
</div>
<div class="class-header source clearfix">
    
    <div class="access-buttons">
        <a class="zep-button" href="../../../../class/PhalconPlus/Logger/Formatter/LinePlus.html">Class</a>

            </div>
    
    <div class="class-full-name">
        
        <span class="class-type">Class</span>
        
                <span class="namespace-piece">
            <a href="../../../../namespace/PhalconPlus.html">PhalconPlus</a>
        </span>
                <span class="namespace-piece">
            <a href="../../../../namespace/PhalconPlus/Logger.html">Logger</a>
        </span>
                <span class="namespace-piece">
            <a href="../../../../namespace/PhalconPlus/Logger/Formatter.html">Formatter</a>
        </span>
                <h1 class="class-name">LinePlus</h1>
    </div>
    
</div>


<pre class="zephir-source-file prettyprint linenums">namespace PhalconPlus\Logger\Formatter;

class LinePlus extends \Phalcon\Logger\Formatter implements \Phalcon\Logger\FormatterInterface
{
    private processors = [];
    // private logLevel = [];
    private formatString = "[%date%][%type%] %message%";

    public function __construct(string! formatString)
    {
        if !empty formatString {
            let this->formatString = formatString;
        }
        //var reflection = null;
        //let reflection = new \ReflectionClass("\Phalcon\Logger");
        //let this->logLevel = array_flip(reflection->getConstants());
    }

    public function format (string! message, type, date, context = [])
    {
        let this->processors["message"] = message;
        let this->processors["date"] = date("Y-m-d H:i:s", date);
        let this->processors["type"] = this->getTypeString(type);

        var matches = [], result;
        let result = preg_match_all("/%(\w+)%/", this->formatString, matches);

        if result == false {
            throw new \InvalidArgumentException("Logger format is not valid: " . this->formatString);
        }

        var replace0, replace1;
        let replace0 = reset(matches);
        let replace1 = end(matches);

        var val1, val2, processors = [];

        for val1 in replace1 {
            if fetch val2, this->processors[val1] {
                let processors[val1] = strval(val2);
            } else {
                let processors[val1] = "undefined";
            }
        }

        var logStr;
        let logStr = str_replace(replace0, array_values(processors), this->formatString);
        return logStr . PHP_EOL;
    }

    public function addProcessor(string! name, <\PhalconPlus\Logger\Processor\AbstractProcessor> processor)
    {
        let this->processors[name] = processor;
    }

    public function __get(string! key)
    {
        return (string) this->processors[key];
    }
}</pre>                </div>
            </div>
        </div>
    </body>
</html>
